<template>
	<view class="main">
		<view class="detail-content">
      <view class="detail-box" @click="payDetail(item)" v-for="(item,index) in historyList" :key="index">
        <view class="left">
          <view class="title">{{item.pay_type|payType}}</view>
          <view class="time">{{item.pay_time|formatDate}}</view>
        </view>
        <view class="num">-{{item.pay_price|formatMoney}}</view>
      </view>
    </view>
    <no-more :list="historyList" :nomore="nomore"></no-more>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				historyList:[],
        pageNo:1,
        pageSize:10,
        nomore:true,
			}
		},
    filters:{
      payType(value){
        switch (value){
          case -1:
            return "未知";
            break;
          case 1:
            return "微信APP支付";
            break;
          case 2:
            return "微信H5支付";
            break;
          case 3:
            return "微信公众号(JSAPI)支付";
            break;
          case 4:
            return "支付宝APP支付";
            break;
          case 5:
            return "支付宝H5支付";
            break;
          case 6:
            return "微信小程序(JSAPI)支付";
            break;
          case 7:
            return "银联云闪付APP支付";
            break;
          case 8:
            return "银联微信APP支付";
            break;
          case 9:
            return "短信验证支付";
            break;
          default:
            return "";
            break;
        }
      }
    },
    onLoad() {
      this.getHistory();
    },
    async onPullDownRefresh(){
      this.pageNo=1;
      this.nomore = false;
      this.historyList=[];
      await this.getHistory();
    },
    //触底加载
    onReachBottom(){
      if (this.nomore) return
      this.pageNo++;
      this.getHistory();
    },
		methods: {
			async getHistory(){
        const res=await this.$api.memberApi.payRecordList({
          pageNo:this.pageNo,
          pageSize:this.pageSize
        });
        if(res.code==0){
          this.historyList=this.historyList.concat(res.data);
          uni.stopPullDownRefresh();
          if (res.data.length < this.pageSize) {
            this.nomore = true
          }
        }
      },
      payDetail(item){
        this.$navigateTo(`/pagesMember/payDetail/index?orderNo=${item.order_no}`,item);
      }
		}
	}
</script>

<style lang="scss" scoped>
.detail-content{
  margin-top: 20rpx;
  background-color: white;
  .detail-box:last-child{
    border-bottom:none;
  }
}
.detail-box{
  display: flex;
  align-items: center;
  padding: 45rpx 0rpx;
  margin: 0rpx 37rpx;
  justify-content: space-between;
  border-bottom: 2rpx solid #EEEEEE;
  .left{
    .title{
      font-size: 28rpx;
      margin-bottom: 10rpx;
    }
    .time{
      color: #999999;
    }
  }
  .right{
    .num{
      font-size: 28rpx;
      color: #000000;
    }
  }
}
</style>
